Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update muted words handling, add attributes #2276

Merged
merged 24 commits into from
Jul 31, 2024

Conversation

estrattonbailey
Copy link
Member

@estrattonbailey estrattonbailey commented Mar 5, 2024

Adds a few new attributes to muted words:

  • id a unique identifier for CRUD actions
  • actors an array of DIDs that the muted word will apply to
  • expiresAt a datetime string representing the time after which the muted word will no longer apply

All these fields are optional. Because CRUD is now based on the id (it was shortsighted on my part not to do this to begin with), the methods have been updated accordingly. Matching is done with preference for id, with fallback to value for legacy words.

With this update, upon any add/update/remove action, all muted words will be checked and migrated if needed. Since this happens on any action, this means that the user only needs to add/update/remove a word once to trigger a full migration and bring their preferences into their latest state.

  • migration here just means generating an id for the word
  • migrations will be attempted on every action
    • we can remove this at some point in the future, or when we re-do private state handling

I added a few tests for these legacy cases, plus reorganized and renamed the other tests for more clarity.

CleanShot 2024-03-06 at 15 55 20@2x

@estrattonbailey estrattonbailey marked this pull request as ready for review March 6, 2024 21:59
@estrattonbailey estrattonbailey changed the title Sketch proposal for additional muted words attributes Update muted words handling, add attributes Mar 6, 2024
@estrattonbailey estrattonbailey force-pushed the eric/mute-words-enhancements branch from 0bd0dbc to ca359ca Compare March 13, 2024 16:14
…cements

* origin/main: (181 commits)
  Minor OAuth client fixes (#2640)
  Version packages (#2639)
  OAuth: 2FA (#2633)
  Version packages (#2622)
  Update data source for `getSuggestedFollowsByActor` (#2630)
  Add in-memory did cache to Ozone backend (#2635)
  Filter out reference lists from `getLists` (#2629)
  lexicons: add missing ozone Tag event type to unions (#2632)
  ✨ Add ozone proxy for getLikes and getRepostedBy (#2624)
  Upgrade pnpm/action-setup in workflows (#2625)
  ✨ Add proxy for user typeahead through ozone (#2612)
  Fix development commands (#2623)
  Add starter packs to post hydration (#2613)
  Social proof blocks (#2603)
  Appview: apply hosting status in getRecord (#2620)
  Add `labelersPref` to `getPreferences` union return types (#2554)
  Version packages (#2618)
  Add new preference and api for bsky app state; also put preference updates within transactional lock regions (#2492)
  remove mentions of sandbox (#2611)
  Appview: simple fix for no-hosted known followers (#2609)
  ...
* Check expiry when comparing mute words

* Check actors when comparing

* Tweak lex, condegen

* Integrate new prop
@sugyan
Copy link
Contributor

sugyan commented Jul 18, 2024

Would you consider merging #2570 in relation to muted words? There is a problem with the current implementation of hasMutedWord.

Copy link
Collaborator

@pfrazee pfrazee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. Very clean

"actorTarget": {
"type": "string",
"description": "Groups of users to apply the muted word to. If undefined, applies to all users.",
"knownValues": ["all", "exclude-following"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC we have a "default" field that might be useful here to indicate what it does if nothing is specified

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah we do! So interesting thing though: this removes the ? optionality of the prop actorTarget. Technically on first read, mute words aren't migrated, so actorTarget for old mute words will always be undefined.

In my latest commit, I opted to map over existing words and insert that default value if actorTarget is undefined.

Cool with that? If not, I think the move would be to remove the default to keep the type optional.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. I dont recall why we wouldve done it that way, other than perhaps because we expected the default value to always get filled in.

I'm totally good w/what you did but up to you

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that it's a little tighter like this so gonna roll with it 👍

…cements

* origin/main:
  Use default Statsig export (#2660)
  remove link to invite code form (#2655)
  Version packages (#2652)
  Priority notification setting (#2648)
  fix(api): `hasMutedWord` for facets with multiple features (#2570)
  Appview: enable insight into full thread context (#2651)
  🐛 include takedowns in post thread for admins (#2642)
@estrattonbailey estrattonbailey force-pushed the eric/mute-words-enhancements branch from 0508d74 to 3c2c06b Compare July 26, 2024 16:17
@estrattonbailey estrattonbailey merged commit 77c5306 into main Jul 31, 2024
10 checks passed
@estrattonbailey estrattonbailey deleted the eric/mute-words-enhancements branch July 31, 2024 21:22
@github-actions github-actions bot mentioned this pull request Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants